
export default {
    namespaced: true,//开启命名空间
    state: {
        song:{},
        songList:[],
        user:{
            cookies:'',
            token:''
        }
    },
    mutations: {
        LoginOut(state){
            state.user.cookies = ''
            state.user.token = ''
        },
        setCookie(state,cookie){
            state.user.cookies = cookie
        },
        setNowSong(state,song){
            state.song = song
        },
        SETMUSIC(state,params){
            state.song = params
            if (state.songList){
                let re = state.songList.some(item => {
                    return item.id === params.id
                })
                if (!re) {
                    state.songList.push(params)
                }
            }else {
                state.songList.push(params)
            }
        },
        RemoveMUSICLIST(state){
            state.songList = []
        },
        ADDMUSICLIST(state,params){
            if (state.songList.length>0){
                let re = state.songList.some(item => {
                    return item.id === params.id
                })
                if (!re) {
                    state.songList.push(params)
                }
            }else {
                state.songList.push(params)
            }
        },
        addMusic(state,list){
            state.songList = []
            state.songList = list
        }

    },
    actions: {
        async addMusicList({commit}, params) {
            console.log(params)
            commit('ADDMUSICLIST',params);
        },
    },
    getters: {
    },
plugins:[]
}
